package com.sybil.ot.dominio;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Embeddable
public class FacturaPK implements Serializable {

   private String folio;
   private int numero;

   public FacturaPK() {
   }

   public FacturaPK(String folio, int numero) {
      this.folio = folio;
      this.numero = numero;
   }

   @Basic(optional = false)
   @NotNull
   @Pattern(regexp = "^[a-zA-Z0-9_-]*$", message = "Sólo se aceptan letras, números, '-' y '_'")
   @Size(min = 1, max = 25, message = "Debe especificar el folio de la factura.")
   @Column(name = "FAOT_FOLIO")
   public String getFolio() {
      return folio;
   }

   public void setFolio(String folio) {
      this.folio = folio;
   }

   @Basic(optional = false)
   @NotNull
   @Column(name = "FAOT_NUMERO")
   public int getNumero() {
      return numero;
   }

   public void setNumero(int numero) {
      this.numero = numero;
   }

   @Override
   public int hashCode() {
      int hash = 0;
      hash += (folio != null ? folio.hashCode() : 0);
      hash += (int) numero;
      return hash;
   }

   @Override
   public boolean equals(Object object) {
      if (!(object instanceof FacturaPK)) {
         return false;
      }
      FacturaPK other = (FacturaPK) object;
      if ((this.folio == null && other.folio != null) || (this.folio != null && !this.folio.equals(other.folio))) {
         return false;
      }
      if (this.numero != other.numero) {
         return false;
      }
      return true;
   }

   @Override
   public String toString() {
      return "FacturaPK[ folio=" + folio + ", numero=" + numero + " ]";
   }
}
